const Clutter = imports.gi.Clutter;
const GDesktopEnums = imports.gi.GDesktopEnums;
const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Lang = imports.lang;
const CROSSHAIRS_CLIP_SIZE = [100, 100];
const NO_CHANGE = 0.0;
+const POINTER_REST_TIME = 1000; // milliseconds
+
// Settings
const APPLICATIONS_SCHEMA = 'org.gnome.desktop.a11y.applications';
const SHOW_KEY = 'screen-magnifier-enabled';
this._xCaret = 0;
this._yCaret = 0;
+ this._pointerIdleMonitor = Meta.IdleMonitor.get_for_device(Meta.VIRTUAL_CORE_POINTER_ID);
+ this._scrollContentsTimerId = 0;
+
Main.layoutManager.connect('monitors-changed',
Lang.bind(this, this._monitorsChanged));
this._focusCaretTracker.connect('caret-moved',
return this._isMouseOverRegion();
},
+ _clearScrollContentsTimer: function() {
+ if (this._scrollContentsTimerId != 0) {
+ Mainloop.source_remove(this._scrollContentsTimerId);
+ this._scrollContentsTimerId = 0;
+ }
+ },
+
+ _scrollContentsToDelayed: function(x, y) {
+ if (this._pointerIdleMonitor.get_idletime() >= POINTER_REST_TIME) {
+ this.scrollContentsTo(x, y);
+ return;
+ }
+
+ this._clearScrollContentsTimer();
+ this._scrollContentsTimerId = Mainloop.timeout_add(POINTER_REST_TIME, Lang.bind(this, function() {
+ this._scrollContentsToDelayed(x, y);
+ return GLib.SOURCE_REMOVE;
+ }));
+ },
+
/**
* scrollContentsTo:
* Shift the contents of the magnified view such it is centered on the given
* @y: The y-coord of the point to center on.
*/
scrollContentsTo: function(x, y) {
+ this._clearScrollContentsTimer();
+
this._followingCursor = false;
this._changeROI({ xCenter: x,
yCenter: y });
else if (this._caretTrackingMode == GDesktopEnums.MagnifierCaretTrackingMode.CENTERED)
[xCaret, yCaret] = this._centerFromPointCentered(xCaret, yCaret);
- this.scrollContentsTo(xCaret, yCaret);
+ this._scrollContentsToDelayed(xCaret, yCaret);
},
_centerFromFocusPosition: function() {
else if (this._focusTrackingMode == GDesktopEnums.MagnifierFocusTrackingMode.CENTERED)
[xFocus, yFocus] = this._centerFromPointCentered(xFocus, yFocus);
- this.scrollContentsTo(xFocus, yFocus);
+ this._scrollContentsToDelayed(xFocus, yFocus);
},
_centerFromPointPush: function(xPoint, yPoint) {